package org.example.sink;

import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommandDescription;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisMapper;

import java.util.UUID;

/**
 * redis 写入
 *
 * @author wlj
 */
public class RedisExampleMapper implements RedisMapper<String> {
    private static final long serialVersionUID = -7957587844848227249L;

    @Override
    public RedisCommandDescription getCommandDescription() {
        // 设置缓存类型，key
        return new RedisCommandDescription(RedisCommand.HSET, "flink:test");
    }

    @Override
    public String getKeyFromData(String string) {
        // 返回key
        return UUID.randomUUID().toString();
    }

    @Override
    public String getValueFromData(String string) {
        // 返回value
        return string;
    }


}
